﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using Microserve.TeleEye.Data;
using Microserve.TeleEye.Common.Utility;
using System.Xml;

namespace Microserve.TeleEye.BusinessServices
{
    public class SectionManager
    {
        public string GetSectionTitle(HttpContext context, string sectionName)
        {
            return new SectionHome().GetSectionTitle(
                PathHelper.GetSectionPath(context, sectionName));
        }

        public string GetSectionSubtitle(HttpContext context, string sectionName)
        {
            return new SectionHome().GetSectionSubtitle(
                PathHelper.GetSectionPath(context, sectionName));
        }

        public string GetSectionAbstract(HttpContext context, string sectionName)
        {
            return new SectionHome().GetSectionAbstract(
                PathHelper.GetSectionPath(context, sectionName));
        }

        public string GetSectionName(HttpContext context, string sectionName)
        {
            return new SectionHome().GetSectionName(
                PathHelper.GetSectionPath(context, sectionName));
        }

        public string GetSectionParentText(HttpContext context, string sectionName)
        {
            string sectionParentText = string.Empty;
            XmlNode parentSection = new SectionHome().GetParentSection(
                PathHelper.GetSectionPath(context, sectionName));


            sectionParentText = XmlDocumentHelper.GetAttributeValue(parentSection, "text");

            return sectionParentText;
        }

        public string GetSectionContent(HttpContext context, string sectionName)
        {
            string sectionParentText = string.Empty;
            
            sectionParentText = new SectionHome().GetSectionContent(
                PathHelper.GetSectionPath(context, sectionName));            

            return sectionParentText.Replace("<![CDATA[", string.Empty).Replace("]]>",string.Empty);
        }

        public string GetSectionParentUrl(HttpContext context, string sectionName)
        {
            string sectionParentText = string.Empty;
            XmlNode parentSection = new SectionHome().GetParentSection(
                PathHelper.GetSectionPath(context, sectionName));


            sectionParentText = XmlDocumentHelper.GetAttributeValue(parentSection, 
                "url");

            return sectionParentText;
        }

    }
}
